﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace weixin
{
    public partial class test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            System.Collections.IDictionaryEnumerator CacheEnum = HttpRuntime.Cache.GetEnumerator();
            while (CacheEnum.MoveNext())
            {
                Response.Write(CacheEnum.Key + "-->" + HttpRuntime.Cache[CacheEnum.Key.ToString()] + "</br>");
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("get_auth_code.aspx");
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            //if (System.Web.HttpRuntime.Cache["pre_auth_code_expires"] == null)
            //{
            //    weixin.api.WXComponent.GetPreAuthCode();
            //}
            Response.Write(GetTuLingApi("hah"));
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("get_auth_code.aspx");
        }

        public string GetTuLingApi(string quest)
        {
            string url = "http://www.tuling123.com/openapi/api";
            string postdata = string.Format("key={0}&info={1}&userid={2}", "4e44a4e8d0bf73bdb0c122b0edc50b78", quest, "007");
            return weixin.api.WXComm.GetHtmlResponse(url + "?" + postdata);
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            Response.Write(weixin.api.WXComm.GetHtmlResponse(TextBox1.Text));
        }
    }
}